    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="main">
        <tr>
       
          <td width="64%" style="padding-bottom:1.2em"><h1>В продаже</h1></td>
          <td width="32%" valign="middle">
          <div style="padding-top:3em">&nbsp;</div>
        </td>
      </tr>
    </table>
    
 <? foreach ($row1->result() as $row1){ ?>
    
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="main" style="">
      <tr>
        <td width="100%" style="margin-top:0em; background-image:url(/images/global/gor_b.gif);background-repeat: no-repeat;">
       
        <div style="margin:0.3em 0 0.4em 0"><a href="/store/catalog/<?=$row1->link?>/"><h3 style="text-decoration: underline;"><?=$row1->name?></h3></a></div>
        
        </td>
      </tr>

        <tr>
          <td style="background-image:url(/images/global/gor_lb.gif);background-repeat: no-repeat;padding-top:1em"> 
        
        <?
        
                    $al=array();
                    $all=array();
                    $row2 = $this->db->query("SELECT id,title,link FROM store WHERE level=2  AND father='$row1->id'");
                  
                    foreach ($row2->result() as $row2){ 

                       $level3 = $this->db->query("SELECT id,title,name,father FROM store where father='$row2->id' and level=3");

                                 foreach ($level3->result() as $row3){
					                   
					                          $level4 = $this->db->query("SELECT * FROM store where father='$row3->id' and level=4 AND available=1");
					                           
                                       
                                                                        
                                       foreach ($level4->result() as $row4){
                                           array_push($al, $row4->id);
                                       }

                                 }
                   }
                  
                 
                  
                  foreach ($al as $row){ 
                  
                   $del = $this->db->query("SELECT id FROM articles WHERE father='$row' AND price !=0 ");
                    if ($del->num_rows() != 0){
                    array_push($all, $row);
                    }
                  }
                  
                  //Если нет товаров вообще
                  if(count($all) == 0){
                  $all=$al;
                  }
                  
                  unset($al); 
                  
               shuffle($all);
                  array_splice($all, 4);
                  
                  
                    foreach ($all as $row){ 
                     //Определяем цену/цены
					$price=$this->Store_model->get_price($row);
				

                  
	               $query=$this->db->query("SELECT * FROM store WHERE id ='$row'");
                   $row = $query->row(); 
                                    
                   $level3=$this->db->query("SELECT id,link, father FROM store WHERE id ='$row->father' LIMIT 1");
                   $level3 = $level3->row();

                   $level2=$this->db->query("SELECT id,link,father FROM store WHERE id ='$level3->father' LIMIT 1");
                   $level2 = $level2->row();
                   
                   $level1=$this->db->query("SELECT id,link,father FROM store WHERE id ='$level2->father' LIMIT 1");
                   $level1 = $level1->row();
                   ?>
             
                   
                          <? if($level1->id != 1){?>     
                          
                                                
                                <div class="side">
                                	<a href="/store/catalog/<?=$level1->link?>/<?=$level2->link?>/<?=$level3->link?>/<?=$row->id?>/">
                                        <div style="background: url(http://rybalka.com.ua/images/store/preview/<?=$row->id?>_1.jpg) no-repeat; height:200px;width:200px ">
                                        <? if($row->action == '1'){ ?>
                                        <img src="/images/global/act.png">
                                        <?}?>
                                        </div>
                                       </a>                     
                                      <div>
                                        <? if($row->brand == 'RM'){ echo "«Рыболовный мир»";}else{ echo $row->brand;}?> <a href="/store/catalog/<?=$level1->link?>/<?=$level2->link?>/<?=$level3->link?>/<?=$row->id?>/"><nobr><?=$row->name?></nobr></a>
                                     </div>
                                     
                                     <div>
                                         <small><?=$row->subhead?></small>
                                      </div>
                                      
                                      <div>
                                         <? if($price !=0){echo "<strong>$price грн</strong>";}else{echo "<span class=\"gray\">Поставка ожидается</span>";} ?>                                  
                                      </div>
                                </div>
                                
                             <?}else{?> 
                             
    

                                  	<div>
	                                   <a href="/store/catalog/<?=$level1->link?>/<?=$level2->link?>/<?=$level3->link?>/<?=$row->id?>/">
	                                               <div style="background:  url(http://rybalka.com.ua/images/store/preview/<?=$row->id?>_1.jpg) no-repeat bottom; height:120px;width:950px ">
                                       <? if($row->action == '1'){ ?>
                                       <img src="/images/global/act.png">
                                       <?}?>
	                                    </div></a>
                                    </div>
                                    
	                                    <div>
		                                    <small><? if($row->brand == 'RM'){ echo "«Рыболовный мир»";}else{ echo $row->brand;}?> <a href="/store/catalog/<?=$level1->link?>/<?=$level2->link?>/<?=$level3->link?>/<?=$row->id?>/"><?=$row->name?></a></small>
		                                 </div>
		                                 
		                                 <div>
		                                     <small><?=$row->subhead?></small>
		                                  </div>
	                                    
	                                                  
	                                    <div style="margin-bottom:2em"><small>
	                                    <?if($price !=0)
	                                    
		                                    {echo "<b>$price грн</b>";}
		                                 else
		                                    {echo "<font color=\"gray\">Поставка ожидается</font>";}
		                                    
	                                    ?></small></div>
                                  
                            
                             
                             <?}?>  
            
            
                 
                  <?}?>
                  
                  <? if($level1->id == 1){?>   
                  <?echo "<br><br>";?>
                  <?}?>
          
          </td>
      </tr>
    </table>

    
    
    
<?}?>


